<div class="container">
	<div class="row">
		<div class="col-md-12 wrap_form_search">
                    <div id="home_search_form">
                    <?php
//                    echo $html->css('/cms/css/jquery.autocomplete.css');
//                    echo $javascript->link('/cms/js/jquery.autocomplete.js');
                    $searchInputId = 'search_'.mt_rand();  // to make autocomplete trigger by dom id instead of class 
                            $text = @$_GET['search'];
                            $category = @$_GET['category'];

                            $textStr = "";
                            $locationStr = "";
//                            if(isset($locationSearch) && $locationSearch)
//                            {
//                                    echo $form->create('Listing',array('url'=>"/listings/index/searchLocation", 'class'=>'form-inline'));
//                                    $locationStr = $form->input('location',array('label'=>$locationLabel,'type'=>"text",'value'=>urldecode($location)));
//                            }else
//                            {
//                                    echo $form->create('Listing',array('url'=>"/listings/index/search"));
//                            }
                            
                            echo $form->create('Listing',array('url'=>"/listings/index/searchCategory", 'class'=>'form-inline'));
                            $textStr = $form->input('search',array('label'=>'','type'=>"text",'placeholder'=>__('What are you looking for?'),'value'=>urldecode($text),'class'=>"form-control", 'id' => $searchInputId));
                            
                            ?>

                        <div class="form-group input_what">
                            <?php echo $textStr; ?>
                        </div>
                        <div class="form-group input_where">
                            <?php
                                    $categories = cri('ListCategory')->getOptions();
                            ?>	
                            <?php echo $form->input('category',array('onchange'=>"getSearchForm(this);",'value'=>'','empty'=>__("-Select-"),'options'=>$categories,'label'=>false, 'class'=>'select sl_category'))?>
                            <?php // echo $locationStr; ?>
                        </div>
                    <?php
                            echo $form->end(array('label'=>__("Søg"),'class'=>"btn btn-default btn_search", 'div'=>array('class'=>'search-submit')));
                    ?>         
                    <div class="clear"></div>
                    <script type="text/javascript">
                    function getSearchForm(obj)
                    {
                        var sear = jQuery(".input.text input").val();
                            jQuery('#home_search_form form').attr('action','/listings/index/searchCategory?search='+sear+'&category='+jQuery(obj).val());
                    }
                    </script>
		</div><!--wrap_form_search--> 
	</div>  
        </div>
</div>	

